package com.yinhai.asynctask;

import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.widget.EditText;
import android.widget.Toast;

public class SubmitFeedbackTask  extends AsyncTaskForHttpProcess{
	String retStr = null;
	private Context context;
	private EditText feedbackContent;
	public SubmitFeedbackTask(Context context,EditText feedbackContent) {
		super(context,false);
		this.context = context;
		this.feedbackContent = feedbackContent;
	}
	
	public SubmitFeedbackTask(Context context, boolean autoForword) {
		super(context, autoForword);
	}

	public SubmitFeedbackTask(Context context, int timeoutRequestCount,
			boolean autoForword) {
		super(context, timeoutRequestCount, autoForword);
	}
	@Override
	protected void parse(Map<String, Object> result) {
		this.retStr = (String)result.get(AsyncTaskContext.RESPONSE_CONTENT);
		JSONObject jo;
		try {
			jo = new JSONObject(retStr);
			
			if("ok".equals(jo.getString("status"))) {
				Toast.makeText(context, "反馈意见提交成功", Toast.LENGTH_LONG).show();
				feedbackContent.setText("");
			} else {
				Toast.makeText(context, jo.getString("message"), Toast.LENGTH_LONG).show();
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
